package com.imranstechnology.homeexpensemanager.utils;

import java.text.NumberFormat;
import java.util.Locale;

public final class StringUtil {
	private static final NumberFormat NF = NumberFormat.getInstance();
	private static final NumberFormat AR_NF = NumberFormat.getInstance(new Locale("ar"));
	public static boolean isEmpty(String value){
		return (value == null || value.length() == 0);
	}
	public String nvl(String value,String defaultValue){
		return (value == null)?defaultValue:value;
	}
	public static float parseStringFloat(String floatString){
		Float ret = 0f;
		try
		{
			ret =  AR_NF.parse(floatString).floatValue();
		}catch(Exception e){
			try
			{
				if(Locale.getDefault().getLanguage().equals("en"))
				{
					ret =  AR_NF.parse(floatString).floatValue();
				}else
				{
					ret =  NF.parse(floatString).floatValue();
				}
			}catch(Exception e1){
				throw new RuntimeException(e1);
			}
		}
		return ret;
	}
}
